<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>球</title>
  <style>
    body{
      width: 100%;
      height: 100%;
      background: #222;
      overflow: hidden;
    }
    .snow {
      animation: mySnow 2s linear infinite; 
    }
    @keyframes mySnow {
      form {
        transform: rotate(0);
      }
      to {
        transform: rotate(360deg);
      }
    }
  </style>
</head>
<body >
</body>
<script>
  // 获取页面的属性
  var bodyH = document.documentElement.clientHeight;
  var bodyW = document.documentElement.clientWidth;
  var number = 0;
  function Snow(x) {
    this.x = x;
    this.y = 0;
    this.CreateBall();
  }
  // 创建雪花
  Snow.prototype.CreateBall = function() {
      var div = document.createElement('div');
      div.id = ++number;
      div.className = 'snow';
      div.style.height =  '32px';
      div.style.width = '32px';
      div.style.background = "url('images/snow.png')";
      div.style.position = 'absolute';
      div.style.left = this.x + 'px';
      div.style.top = '0px';
      document.documentElement.appendChild(div);
      this.down(div)
  }
  // 雪花下落
  Snow.prototype.down = function(div) {
    var x = parseInt(div.style.left);
      var y = 0;
      setInterval(function(){
        div.style.left = (x++) + 'px';
        div.style.top = (y++) + 'px';
      }, 10)
  }
  setInterval(function(){
    var ball = new Snow(Math.floor(Math.random() * parseInt(window.screen.width)));
  }, 100)
  console.log(Math.floor(Math.random()*6 + 25))
</script>
</html>